<?php 
@session_start();
if(!isset($_SESSION['usuCod'])){   
	echo "<script>window.location.href='index.php'</script>";
}
require('lib/conexion.php');

 //descargar archivo

		
		$sql1="SELECT dq.docr_nombre,dq.docr_url,dq.docr_extension,dq.docr_estado,dq.docr_fechaCreacion
		FROM documentosxrequisitos dq INNER JOIN requisitos re ON re.req_codigo=dq.req_codigo
		WHERE dq.req_codigo=".$_REQUEST['coreJS']." AND (dq.usu_codPropietario=".$_SESSION['usuCod']." 
		OR re.usu_codSeguimiento=".$_SESSION['usuCod'].") AND dq.docr_estado='A' ";
		$rs1=mysql_query($sql1);
		$row1=mysql_fetch_array($rs1);
		                
        //$path = $root; */
		$file = $row1['docr_nombre'];
		$path =$row1['docr_url'];
        $type = '';

        if (is_file($path)) {
            $size = filesize($path);
            if (function_exists('mime_content_type')) {
                $type = mime_content_type($path);
            } else if (function_exists('finfo_file')) {
                $info = finfo_open(FILEINFO_MIME);
                $type = finfo_file($info, $path);
                finfo_close($info);
            }
            if ($type == '') {
                $type = "application/force-download";
            }
            // Set Headers
            header("Content-Type: $type");
            header("Content-Disposition: attachment; filename=$file");
            header("Content-Transfer-Encoding: binary");
            header("Content-Length: " . $size);
            // Download File
            readfile($path);
            return true;
        } else {
            return false;
           // die("File not exist !!");
        }
       
	   
?>